﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Panel.Master" Inherits="System.Web.Mvc.ViewPage<IList<Prodma.DataAccess.Models.ViewModels.UrunlerVm>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<form id="arama" method="post" action="/Urunler/Index/" onsubmit="return false;">
    <div class="listHeader">
        <img src="../../Images/ListImages/userlist.png" alt="" class="listHeaderIco" />
        <div class="listHeaderText">Siparişler</div>        
        <div class="listHeaderMenuBox">
            <% Html.RenderPartial("/views/shared/userControls/Navigation.ascx",
                  Prodma.DataAccess.Authorization.Authorization.GetNavigation("urunler", 3));%>
        </div>
    </div>

    <div class="listFindMenu">       
        <% Html.RenderPartial("/views/shared/userControls/ProductSelector.ascx", ViewData["selectedList"], new ViewDataDictionary()); %>
    </div>
</form>

<form id="urunler" class="urunlerContainer" method="Post" action="/Sepet/AddChartTotal">
 <div id="urunlerList">
    <% Html.RenderPartial("/views/shared/userControls/UrunlerList.ascx", ViewData.Model); %>
</div>  
<%--  <div class="listFooterContainer">
            <div class="listFooter">
                <input type="hidden" value="<%=ViewData["TotalRowCount"] %>" name="rowCount"/>
            </div>        

        </div> --%>
    
</form>
<form id="sepet" class="sepetContainer2" method="Post" action="/Sepet/OrderChart">
<div id="sepetList">
 <% Html.RenderPartial("/views/shared/userControls/SepetList.ascx", ViewData["Sepet"]); %>
 </div>
</form>
<%--<form id="productDetail" method="post" action="">
<div id="detail" class="productDetail">
</div>
</form>--%>

    <link rel="stylesheet" href="../../Styles/Panel.css" type="text/css" />
    <link rel="stylesheet" href="../../Styles/ProductDetail.css" type="text/css" />
<script type="text/javascript">
    
    function submitForm() {
        document.forms["urunler"].submit();
    }


    function formSubmit(satir) {
        var form = document.getElementById('urunler')
        form.action = '/Sepet/AddChart/' + satir
        form.submit();
    }

    function showBigPhoto() { 
    alert("tamam")
}

function doubleClick(urunId) {
                var sepet = new Boolean();
                $.post('/sepet/ControlChart/', { UrunId: urunId }, function (data) {
                    sepet = data;
                    alert(sepet);
                    if (sepet) {
                        var miktar = prompt("Lütfen miktar giriniz.", "0");
                        if (miktar != null && miktar != "") {

                            $.post(
                                "/sepet/AddChartDynamic/", { quantity: miktar, id: urunId }, function (data2) {
                                    document.getElementById('sepetList').innerHTML = data2;
                                });

                        }
                    }
                    else {
                        alert('Bu üründen sepetinizde mevcut');
                        var miktar = prompt("Lütfen miktar giriniz.", "0");
                        if (miktar != null && miktar != "") {

                            $.post(
                                "/sepet/AddChartDynamic/", { quantity: miktar, id: urunId }, function (data2) {
                                    document.getElementById('sepetList').innerHTML = data2;
                                });
                        }
                    }
                });
            }

            function handleKeyPress(e, counter) {
                var key = e.keyCode || e.which;
                if (key == 13) {
                    var miktar = document.getElementById('SText' + counter).value;
                    var urunId = document.getElementById('SProduct' + counter).value;
                    var chartid = document.getElementById('SChart' + counter).value;
                    $.post(
                                "/sepet/OrderChartDynamic/", { quantity: miktar, id: urunId, chartId: chartid }, function (data2) {
                                    document.getElementById('sepetList').innerHTML = data2;
                                });
                }
                        }

            function sil(satir) {
                var chartid = document.getElementById('SChart' + satir).value;

                $.post(
                    "/sepet/DeleteDynamic/", { chartId: chartid }, function (data2) {
                        document.getElementById('sepetList').innerHTML = data2;
                    });
                }

            function clearChart() {
                $.post(
                "/sepet/ClearChart/", {}, function (data2) {
                    document.getElementById('sepet').innerHTML = data2;
                });
            }


//                function openProductDetail(urunId) {

//                    $.post(
//                    "/Urunler/ProductDetail/", { id: urunId }, function (data2) {
//                        document.getElementById('detail').innerHTML = data2;
//                    });

//                    emailwindow = dhtmlmodal.open('detail', 'iframe', '/views/shared/userControls/ProductDetail.ascx', 'Ürün Detayı', 'width=700px,height=400px')

//                    emailwindow.onclose = function () { //Define custom code to run when window is closed
//                        var theform = this.contentDoc.forms[0] //Access first form inside iframe just for your reference
//                        var theemail = this.contentDoc.getElementById("emailfield") //Access form field with id="emailfield" inside iframe
//                        if (theemail.value.indexOf("@") == -1) { //crude check for invalid email
//                            alert("Please enter a valid email address")
//                            return false //cancel closing of modal window
//                        }
//                        else { //else if this is a valid email
//                            document.getElementById("youremail").innerHTML = theemail.value //Assign the email to a span on the page
//                            return true //allow closing of window
//                        }
//                    }
            //                }

//            $().ready(
//            function ShowDialog(urunId) {
//                alert(urunId);
//                $.get('/Urunler/ProductDetail_2/', { UrunId: urunId }, function (htmlResult) {
//                    $("#ProductDetail").remove(); //In case this is the second time they've requested the dialog.
//                    $("#urunlerList").append(htmlResult);
//                    $("#ProductDetail").dialog();
//                }
//                );
//                return false;
//            });
</script>


</asp:Content>
